<html>
<head><meta charset="utf-8"><title>Insignificant drops · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html">Insignificant drops</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241319536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241319536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241319536">(Jun 02 2021 at 21:02)</a>:</h4>
<p>As part of the RFC 2229 migration plan, we discussed to annotate certain Drop implementations within the stdlib with the attribute <code>#[rustc_insignificant_drop]</code>. This was introduced as part of <a href="https://github.com/rust-lang/rust/issues/84152">#84152</a>. </p>
<p>The idea of this attribute is annotate types that can safely drop-reordered (current metric being that they only free memory) and will not be triggered as part of the migration lint for 2229.</p>
<p>Our current plan to finding which types should be annotated is to:</p>
<ul>
<li>Do collections because they are mostly freeing memory</li>
<li>drain/into_iter will possibly free memory</li>
<li>Run lint on compiler</li>
<li>Go through all Drop impl in stdlib</li>
</ul>
<p>We just want to make sure that T-LIBS didn't have any concerns with us making the annotations or our approach or if you all have any suggestions for us?</p>



<a name="241319558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241319558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241319558">(Jun 02 2021 at 21:03)</a>:</h4>
<p>cc <span class="user-group-mention" data-user-group-id="1175">@WG-rfc-2229</span></p>



<a name="241326071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326071">(Jun 02 2021 at 22:07)</a>:</h4>
<p>I'd be curious <span class="user-group-mention" data-user-group-id="2645">@T-libs</span> if you (a) agree that drops that only free memory are likely "not significant" in the sense that it's ok if they run at a different time than before or (b) can think of any other categories of drops off the top of your head that fit that definition. We expect that going through the results from libstd/compiler may yield some new examples that we didn't think of to start.</p>



<a name="241326221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326221">(Jun 02 2021 at 22:08)</a>:</h4>
<p>recursively Arc/Rc dropping reference counts if that can only lead to an "insignificant drop", potentially</p>



<a name="241326315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326315">(Jun 02 2021 at 22:09)</a>:</h4>
<p>(a) yes.<br>
(b) hm, let me quickly grep for all Drop impls in std, to see if anything stands out.</p>



<a name="241326442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326442">(Jun 02 2021 at 22:10)</a>:</h4>
<p>I think <code>Arc</code>/<code>Rc</code> are "significant" because they may leave dangling <code>Weak</code> if dropped early, no longer upgradable</p>



<a name="241326465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326465">(Jun 02 2021 at 22:10)</a>:</h4>
<p>heh, we have surprisingly few Drop implementations in std.</p>



<a name="241326566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326566">(Jun 02 2021 at 22:11)</a>:</h4>
<p>i think in many cases people wouldn't really care when exactly their File gets dropped, but that's not as universal as just dropping some memory allocation.</p>



<a name="241326571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326571">(Jun 02 2021 at 22:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="138448">cuviper</span> <a href="#narrow/stream/219381-t-libs/topic/Insignificant.20drops/near/241326442">said</a>:</p>
<blockquote>
<p>I think <code>Arc</code>/<code>Rc</code> are "significant" because they may leave dangling <code>Weak</code> if dropped early, no longer upgradable</p>
</blockquote>
<p>This is a good point I had not considered. I guess it is likely that they show up rarely in practice anyway. More broadly, it probably makes sense to run crater with some logging for the cases where we're expecting to change behavior so we can identify the "top N" causes and consider whether an annotation makes sense.</p>



<a name="241326684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326684">(Jun 02 2021 at 22:12)</a>:</h4>
<p>how does this attribute behave for generic collections? e.g. Vec&lt;u8&gt; is insignificant, but Vec&lt;MutexGuard&gt; is.</p>



<a name="241326707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326707">(Jun 02 2021 at 22:13)</a>:</h4>
<p>that's what I was going to bring up</p>



<a name="241326718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326718">(Jun 02 2021 at 22:13)</a>:</h4>
<p>I don't get how collections are insignificant, since they could wrap significant types</p>



<a name="241326721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326721">(Jun 02 2021 at 22:13)</a>:</h4>
<p>or would this be transitive somehow</p>



<a name="241326847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241326847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241326847">(Jun 02 2021 at 22:14)</a>:</h4>
<p>so (b): no, i don't see any other Drop impls which would be as insignificant as deallocations</p>



<a name="241327055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241327055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241327055">(Jun 02 2021 at 22:17)</a>:</h4>
<p>does reordered drop also mean it may be delayed from where it was before? even this has potential OOM impact</p>



<a name="241328329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241328329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241328329">(Jun 02 2021 at 22:32)</a>:</h4>
<p>Drops that only free memory are definitely "not significant" - LLVM already considers elimination of dynamic memory allocation to be allowed</p>



<a name="241328387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241328387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241328387">(Jun 02 2021 at 22:33)</a>:</h4>
<p>LLVM only does that for the default allocator, right?</p>



<a name="241328399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241328399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241328399">(Jun 02 2021 at 22:33)</a>:</h4>
<p>A custom allocator might have side effects that are considered "significant"</p>



<a name="241328697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241328697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241328697">(Jun 02 2021 at 22:37)</a>:</h4>
<p>eliminating a malloc/free pair is one thing, but I'm only talking about reordering</p>



<a name="241328726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241328726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241328726">(Jun 02 2021 at 22:37)</a>:</h4>
<p>like malloc,free,malloc,free into malloc,malloc,free,free</p>



<a name="241329045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241329045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241329045">(Jun 02 2021 at 22:42)</a>:</h4>
<p>I believe our LLVM fork treats calls to the global allocator (whatever that is configured to be) as insignificant, yeah</p>



<a name="241331801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241331801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241331801">(Jun 02 2021 at 23:20)</a>:</h4>
<p>So, even drops that "only free memory" could potentially affect unsafe code if reordered. I personally would love to see such reordeing, but lang at one point thought it would be high-risk.</p>



<a name="241331811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241331811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241331811">(Jun 02 2021 at 23:20)</a>:</h4>
<p>Moving it <em>later</em> shouldn't ever be a problem, though.</p>



<a name="241331814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241331814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241331814">(Jun 02 2021 at 23:20)</a>:</h4>
<p>But moving it earlier might be.</p>



<a name="241335516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241335516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241335516">(Jun 03 2021 at 00:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/219381-t-libs/topic/Insignificant.20drops/near/241326684">said</a>:</p>
<blockquote>
<p>how does this attribute behave for generic collections? e.g. Vec&lt;u8&gt; is insignificant, but Vec&lt;MutexGuard&gt; is.</p>
</blockquote>
<p>If one of the generic being used is a significant drop type, then Vec&lt;T&gt; is a significant drop.</p>
<p>Example: <a href="https://github.com/sexxi-goose/rust/blob/a7e1cec621d751b1c10b00b45c5b228df1b7d46d/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs#L47-L63">https://github.com/sexxi-goose/rust/blob/a7e1cec621d751b1c10b00b45c5b228df1b7d46d/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs#L47-L63</a></p>



<a name="241335766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241335766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241335766">(Jun 03 2021 at 00:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Insignificant.20drops/near/241331811">said</a>:</p>
<blockquote>
<p>Moving it <em>later</em> shouldn't ever be a problem, though.</p>
</blockquote>
<p>At least the way I understand it we will be performing some drops later when the feature is enabled. Because the closure is still being dropped at the same point as before it is just not capturing some of the structures completely</p>



<a name="241335976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241335976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241335976">(Jun 03 2021 at 00:21)</a>:</h4>
<p>Actually, in this example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w">  </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="fm">vec!</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[[</span><span class="mi">1</span><span class="p">]);</span><span class="w"></span>

<span class="n">prinln</span><span class="o">!</span><span class="p">(</span><span class="s">"{:#?}"</span><span class="p">,</span><span class="w"> </span><span class="n">t</span><span class="p">.</span><span class="mi">0</span><span class="p">);</span><span class="w"> </span><span class="c1">// t.0 not needed anymore</span>

<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">t</span><span class="p">.</span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
</code></pre></div>
<p>Under any lifetime anlaysis/ optimization will t.0 be dropped before t.1, because it is not needed anymore?</p>



<a name="241336068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241336068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241336068">(Jun 03 2021 at 00:22)</a>:</h4>
<p>borrowck doesn't change drop -- <code>t.0</code> will drop at the end of <code>t</code>'s scope</p>



<a name="241336087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241336087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241336087">(Jun 03 2021 at 00:23)</a>:</h4>
<p>but that could be arbitrarily before or after the closure, depending on how that is moved around</p>



<a name="241336226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241336226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241336226">(Jun 03 2021 at 00:25)</a>:</h4>
<p>e.g. <code>c</code> could be called and consumed right away, or it could be returned from this context and get called much later</p>



<a name="241345325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241345325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241345325">(Jun 03 2021 at 03:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Insignificant.20drops/near/241331814">said</a>:</p>
<blockquote>
<p>But moving it earlier might be.</p>
</blockquote>
<p>So this can be a problem right?</p>



<a name="241345461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Insignificant%20drops/near/241345461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Insignificant.20drops.html#241345461">(Jun 03 2021 at 03:41)</a>:</h4>
<p>eg:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">f</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="nb">Fn</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="fm">vec!</span><span class="p">[],</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[]);</span><span class="w"></span>

<span class="w">     </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="fm">println!</span><span class="p">(</span><span class="n">t</span><span class="p">.</span><span class="mi">0</span><span class="p">);</span><span class="w"></span>

<span class="w">     </span><span class="n">c</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Before <code>t.1</code> would be dropped in whichever scope <code>c</code> is last used, but now it's being dropped possibly much before</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>